﻿#ifndef TYPEDEF_H
#define TYPEDEF_H

//---------------------------------------------------------------


#ifndef NULL
#define NULL	((void *) 0)
#endif

#ifndef TRUE
#define	TRUE	1
#endif

#ifndef FALSE
#define	FALSE	0
#endif


//---------------------------------------------------------------


#define	DATA_VALID		0x55AA

//---------------------------------------------------------------

typedef int BOOL;
typedef unsigned char       BYTE;
typedef unsigned short int  WORD;
typedef unsigned long  int  DWORD;

typedef unsigned char       u8;
typedef unsigned short int  u16;
typedef unsigned int        u32;
typedef char                s8;
typedef short int           s16;
typedef int                 s32;

//---------------------------------------------------------------

#define U8_MAX     ((u8)255)
#define S8_MAX     ((s8)127)
#define S8_MIN     ((s8)(-128))
#define U16_MAX    ((u16)65535u)
#define S16_MAX    ((s16)32767)
#define S16_MIN    ((s16)(-32768))
#define U32_MAX    ((u32)4294967295uL)
#define S32_MAX    ((s32)2147483647uL)
#define S32_MIN    ((s32)(-2147483648uL))

//---------------------------------------------------------------
#ifndef LOBYTE
#define LOBYTE(w)		((BYTE)(((WORD)(w)) & 0xff))
#endif

#ifndef HIBYTE
#define HIBYTE(w)		((BYTE)((((WORD)(w)) >> 8) & 0xff))
#endif

#ifndef LOWORD
#define LOWORD(l)		((WORD)(((DWORD)(l)) & 0xffff))
#endif

#ifndef HIWORD
#define HIWORD(l)		((WORD)((((DWORD)(l)) >> 16) & 0xffff))
#endif

#ifndef MAKEWORD
#define MAKEWORD(a, b)	((WORD)((BYTE)(a)) | (((WORD)((BYTE)(b))) << 8))
#endif

#ifndef MAKEDWORD
#define MAKEDWORD(a, b)	((DWORD)((WORD)(a)) | (((DWORD)((WORD)(b))) << 16))
#endif

#ifndef LOHFBYTE
#define LOHFBYTE(b)		((BYTE)((b) & 0x0f))
#endif

#ifndef HIHFBYTE
#define HIHFBYTE(b)		((BYTE)(((b) >> 4) & 0x0f))
#endif

#ifndef MAKEBYTE
#define MAKEBYTE(a, b)	((BYTE)((BYTE)((a) & 0x0f)) | ((BYTE)(((BYTE)((b) & 0x0f)) << 4)))
#endif

#ifndef MIN
#define MIN(a, b)		((a) < (b) ? (a) : (b))
#endif

#ifndef MAX
#define MAX(a, b)		((a) > (b) ? (a) : (b))
#endif

//---------------------------------------------------------------

#ifndef PI

#define PI	3.1415926535897932

#endif




#endif // TYPEDEF_H
